package leetcode;

import java.util.Hashtable;
import java.util.Iterator;
import java.util.Set;

/**
 * @param
 * @author oyz
 * @version 1.0.4
 * @description:数组中重复的数
 * @date 2022/12/5 22:52
 */
public class Offer03 {
    public static int findRepeatNumber(int[] nums) {
        Hashtable<Integer,Integer> tmp = new Hashtable<>();
        for(int i = 0; i < nums.length; i++) {
            // 判断是否在map里边存在
            if(tmp.containsKey(nums[i])) {
                tmp.put(nums[i], 2);
            }else {
                tmp.put(nums[i], 1);
            }
        }
        for(Integer i : tmp.keySet()) {
            if(tmp.get(i) == 2){
                return i;
            }
        }
        return 0;
    }

    public static void main(String[] args) {
        int arr [] = {2, 3, 1, 0, 2, 5, 3};
        System.out.println(findRepeatNumber(arr));
    }

}
